package com.qqq.commonrabbitmq.config;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Rabbitmq配置
 */
@Configuration
public class RabbitMqCommonConfig {

    @Bean("testQueue")
    public Queue workQueue() {
        return QueueBuilder.durable("testQueue").build();
    }

    /**
     * json 序列化转换器
     * @return 序列化转换器
     */
    @Bean
    public MessageConverter jsonToMapMessageConverter() {
        return new Jackson2JsonMessageConverter();
    }
}
